package com.gtja.beoms.base;

/**
 * <p>
 *  基础响应类
 * </p>
 *
 * @author hudongling
 * @version 1.0.0
 * @since 1.0.0
 *
 */
public class CommonResponse {
	
	private static final String DEFAULT_SUCCESS_CODE = "000000";
    private static final String DEFAULT_ERROR_CODE = "999999";
    private static final String DEFAULT_SUCCESS_MSG = "SUCCESS";
	
	private boolean success = false;
	private String resultCode = DEFAULT_ERROR_CODE;
	private String resultMsg ;
    private Object data;

    public static CommonResponse success() {
    	CommonResponse response = new CommonResponse();
    	response.setSuccess(true);
    	response.setResultCode(CommonResponse.DEFAULT_SUCCESS_CODE);
		response.setResultMsg(CommonResponse.DEFAULT_SUCCESS_MSG);
		return response;
    }
    
    public static CommonResponse success(Object data) {
    	CommonResponse response = new CommonResponse();
    	response.setSuccess(true);
    	response.setResultCode(CommonResponse.DEFAULT_SUCCESS_CODE);
		response.setResultMsg(CommonResponse.DEFAULT_SUCCESS_MSG);
		response.setData(data);
		return response;
    }

    
    public static CommonResponse error(String errMsg) {
    	CommonResponse response = new CommonResponse();
    	response.setSuccess(false);
    	response.setResultCode(CommonResponse.DEFAULT_ERROR_CODE);
		response.setResultMsg(errMsg);
		return response;
    }
    
	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getResultMsg() {
		return resultMsg;
	}

	public void setResultMsg(String resultMsg) {
		this.resultMsg = resultMsg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}




	@Override
	public String toString() {
		return "{" +
				"success=" + success +
				", resultCode='" + resultCode + '\'' +
				", resultMsg='" + resultMsg + '\'' +
				", data=" + data +
				'}';
	}
}